#!/bin/bash
# add values in an array
testit (){
    local sum=0
    local newarray
    newarray=($(echo "$@"))
    for i in ${newarray[*]}; do 
        sum=$[ $i + $sum ]
    done
    echo "$sum"

}

myarray=(0 1 2 3 4 5)
echo "The original array is ${myarray[*]}"
arg1=$(echo "${myarray[*]}")
result=$(testit $arg1)
echo "The result is $result"

